#ifndef SCENEIO_H
#define SCENEIO_H

#include <string>
#include <map>
#include <vector>


class QString;
class QFile;
class QDomDocument;
class QDomElement;
class QDomNode;

class Scene;
class ObjMesh;
class Object;
class Light;
class Transform;
class Material;


class SceneIO
{
public:
    SceneIO(const std::string& path);
    ~SceneIO();

    void saveScene(Scene*);
    Scene* loadScene();

private:
    QDomElement createRootElement(Scene*);
    QDomElement createObjectElement(Object*);
    QDomElement createLightElement(Light*);
    QDomElement createTransformElement(const Transform&);
    QDomElement createMaterialElement(Material*);

    void parseRootElement(const QDomElement &element);
    Object* parseObjectElement(const QDomElement &element);
    Light* parseLightElement(const QDomElement &element);
    Transform parseTransform(const QDomElement &element);
    Material* parseMaterial(const QDomElement &element);
    float* parseFloatArray3(const QString& str);

    std::vector<Object*> m_objects;
    std::vector<Light*> m_lights;
    QFile* file;
    QDomDocument* doc;
};



#endif // SCENEIO
